package com.ddxcloud.movie.controller;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ddxcloud.common.utils.Result;
import com.ddxcloud.movie.data.dto.CinemasDTO;
import com.ddxcloud.movie.data.dto.PageDTO;
import com.ddxcloud.movie.data.dto.ShowsDTO;
import com.ddxcloud.movie.data.vo.SeatsVO;
import com.ddxcloud.movie.data.vo.ShowsVO;
import com.ddxcloud.movie.service.MoviesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/movies")
@Api(tags="电影")
public class MoviesController {

    @Resource
    MoviesService moviesService;

    /**
     * 获取城市列表
     * @return
     */
    @ApiOperation( "获取城市列表")
    @GetMapping("/getAllCity")
    public Result<JSONObject> getAllCity(){
        return Result.success(moviesService.getAllCity());
    }

    /**
     * 获取当前所在城市
     * @param location
     * @return
     */
    @ApiOperation( "获取当前所在城市")
    @GetMapping("/getCity")
    public Result<Object> getCity(@RequestParam String location){
        return Result.success(moviesService.getCity(location));
    }

    /**
     * 获取已上映电影
     * @param dto
     * @return
     */
    @ApiOperation("获取已上映电影")
    @GetMapping("/getMovies")
    public Result<IPage<Object>> getMovies(PageDTO dto) {
        return Result.success(moviesService.getMovies(dto));
    }

    /**
     * 获取未上映电影
     * @param dto
     * @return
     */
    @ApiOperation("获取未上映电影")
    @GetMapping("/getFutureMovies")
    public Result<IPage<Object>> getFutureMovies(PageDTO dto) {
        return Result.success(moviesService.getFutureMovies(dto));
    }

    /**
     * 获取单个电影信息
     * @param filmId
     * @return
     */
    @ApiOperation("获取单个电影信息")
    @GetMapping("/getMovieInfo")
    public Result<JSONObject> getMovieInfo(String filmId) {
        return Result.success(moviesService.getMovieInfo(filmId));
    }

    /**
     * 获取影院列表
     * @param dto
     * @return
     */
    @ApiOperation("获取影院列表")
    @GetMapping("getCinemas")
    public Result<List> getCinemas(CinemasDTO dto) {
        return Result.success(moviesService.getCinemas(dto));
    }

    /**
     * 获取单个影院信息
     * @param cityId
     * @param cinemaId
     * @return
     */
    @ApiOperation("获取单个影院信息")
    @GetMapping("/getCinemaInfo")
    public Result<JSONObject> getCinemaInfo(
            @RequestParam("cityId") String cityId,
            @RequestParam("cinemaId")String cinemaId) {
        return Result.success(moviesService.getCinemaInfo(cityId, cinemaId));
    }

    /**
     * 获取影院排期
     * @param dto
     * @return
     */
    @ApiOperation("获取影院排期")
    @GetMapping("/getShows")
    public Result<List<ShowsVO>> getShows(ShowsDTO dto) {
        return Result.success(moviesService.getShows(dto));
    }

    /**
     * 获取座位
     * @param showId
     * @param cinemaId
     * @return
     */
    @ApiOperation("获取座位")
    @GetMapping("/getSeats")
    public Result<SeatsVO> getSeats(
            @RequestParam("showId") String showId,
            @RequestParam( "cinemaId") String cinemaId) {
        return Result.success(moviesService.getSeats(showId,cinemaId));
    }
}
